name: benchmarks
on:
  push:
    branches:
      - main
jobs:
  run:
    runs-on: [ubuntu-latest]
    container: ghcr.io/iterative/cml
    steps:
      - uses: actions/checkout@v4
      - name: cml_run
        env:
          CML_DRIVER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          # See https://github.com/actions/checkout/issues/760
          git config --global --add safe.directory /__w/datasets/datasets

          # Your ML workflow goes here

          pip install --upgrade pip
          pip install setuptools wheel
          pip install -e .[benchmarks]

          # pyarrow==8.0.0
          pip install pyarrow==8.0.0

          dvc repro --force

          git fetch --prune
          dvc metrics diff --json main > report.json

          python ./benchmarks/format.py report.json report.md

          echo "<details>\n<summary>Show benchmarks</summary>\n\nPyArrow==8.0.0\n" > final_report.md
          cat report.md >> final_report.md

          # pyarrow
          pip install pyarrow --upgrade

          dvc repro --force

          git fetch --prune
          dvc metrics diff --json main > report.json

          python ./benchmarks/format.py report.json report.md

          echo "\nPyArrow==latest\n" >> final_report.md
          cat report.md >> final_report.md
          echo "\n</details>" >> final_report.md

          cml comment create final_report.md
